#!/bin/bash

if [ -f makefiles/mandelbulber ] ; then
  sudo install makefiles/mandelbulber /usr/bin
elif [ -f usr/bin/mandelbulber ] ; then
  sudo install usr/bin/mandelbulber /usr/bin
else
  echo Binary file not found. Program not compilled.
  echo Do you want to compile program now? [y/n]
  read answer
  if [ "$answer" = "y" ] ; then
    cd makefiles/
	make all
	rm src/*.o
	rm src/*.d
	cd ..
	mv makefiles/mandelbulber usr/bin/mandelbulber
	sudo install usr/bin/mandelbulber /usr/bin
  fi
fi

sudo mkdir /usr/share/mandelbulber
sudo cp -ua usr/share/* /usr/share/mandelbulber

sudo desktop-file-install mandelbulber.desktop

echo mandelbulber installed successfully
echo to run please type "mandelbulber" or select from system menu
